<h1>Edit Photo</h1>
<form onsubmit="return validate_edit_photo(this)" method="post" action="<?php echo BASE_PATH; ?>/photos/edit/<?php echo $photo["Photo"]["id"]; ?>" enctype="multipart/form-data">
    <fieldset>
        <label for="category">Category:</label>
        <input type="text" name="category" value="<?php echo $photo["Photo"]["category"]; ?>" id="category"/><br />

        <label for="category">Title:</label>
        <input type="text" name="title" value="<?php echo $photo["Photo"]["title"]; ?>" id="title"/><br />

        <label for="description">Description:</label>
        <textarea cols="" rows="" name="description" id="description"><?php echo $photo["Photo"]["description"]; ?></textarea><br />

        <label for="keywords">Keyword(s):</label>
        <input type="text" name="keywords" value="<?php echo $photo["Photo"]["keywords"]; ?>" id="keywords"/><br />

        <label for="date_taken">Date Taken:</label>
        <input type="text" name="date_taken" value="<?php echo $photo["Photo"]["date_taken"]; ?>" id="date_taken" onclick="displayDatePicker('date_taken');"/><br />

        <label for="access_rule">Access Rule:</label>
        <select name="access_rule" id="access">
            <option value="1" <?php if ($photo["Photo"]["access_rule"] == 1) echo "selected"; ?>>Unrestricted</option>
            <option value="2" <?php if ($photo["Photo"]["access_rule"] == 2) echo "selected"; ?>>Only logged users</option>
            <option value="3" <?php if ($photo["Photo"]["access_rule"] == 3) echo "selected"; ?>>Only followers</option>
            <option value="4" <?php if ($photo["Photo"]["access_rule"] == 4) echo "selected"; ?>>Private</option>
        </select><br />

        <label for="comment_rule">Comment Rule:</label>
        <select name="comment_rule" id="comment">
            <option value="1" <?php if ($photo["Photo"]["comment_rule"] == 1) echo "selected"; ?>>Unrestricted</option>
            <option value="2" <?php if ($photo["Photo"]["comment_rule"] == 2) echo "selected"; ?>>Closed</option>
        </select><br />
        <label for="tag">In This Photo:</label><br/>
        <?php
        if((count($tags) > 0) && (!isset($_SESSION['tag']))) {
            $_SESSION['tag_list'] = array();
            $iter=0;
            foreach($tags as $tag):
                $_SESSION['tag_list'][$iter] = $tag['User']['name'];
                $iter++;
        ?>
            <input type="hidden" name="tag[]" value="<?php echo $tag['User']['name']; ?>" /><label class="labeluser"><?php echo $tag['User']['name']; ?></label><br/>
        <?php
            endforeach;
        } else if(isset($_SESSION['tag'])) {
            if(isset($_SESSION['tag_list'])):
                foreach($this->session->get('tag_list') as $tag_list):
        ?>
            <input type="hidden" name="tag[]" value="<?php echo $tag_list; ?>" /><label class="labeluser"><?php echo $tag_list; ?></label><br/>
        <?php 
                endforeach;
            else: ?>
            <input type="hidden" name="tag[]" value="Empty" /><label class="labeluser">No one in this photo</label><br/>
        <?php
            endif;
            $this->session->remove('tag');
        } else { ?>
            <input type="hidden" name="tag[]" value="Empty" /><label class="labeluser">No one in this photo</label><br/>
        <?php } ?>
        <span id="block"><input type="button" onclick="popUp('<?php echo BASE_PATH; ?>/photos/add_tag')" value="Choose User" id="popup"/></span><br />
        <input type="submit" name="submit" id="submit" value="Update" />
    </fieldset>
</form>